home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Concept 6
/
CD Concept 06.iso
/
mac
/
UTILITAIRE
/
RLaB
/
testmatrix
/
pdtoep.r
< prev
next >
Wrap
Text File
|
1994-12-20
|
2KB
|
54 lines
//-------------------------------------------------------------------//
// Synopsis: Symmetric positive definite Toeplitz matrix.
// Syntax: P = pdtoep ( N , M , W , THETA )
// Description:
// P is an N-by-N symmetric positive (semi-) definite (SPD)
// Toeplitz matrix, comprised of the sum of M rank 2 (or, for
// certain THETA, rank 1) SPD Toeplitz matrices. Specifically,
// T = W(1)*T(THETA(1)) + ... + W(M)*T(THETA(M)),
// where T(THETA(k)) has (i,j) element COS(2*PI*THETA(k)*(i-j)).
// Defaults: M = N, W = rand(M,1), THETA = rand(M,1).
// Reference:
// G. Cybenko and C.F. Van Loan, Computing the minimum eigenvalue of
// a symmetric positive definite Toeplitz matrix, SIAM J. Sci. Stat.
// Comput., 7 (1986), pp. 123-131.
// This file is a translation of pdtoep.m from version 2.0 of
// "The Test Matrix Toolbox for Matlab", described in Numerical
// Analysis Report No. 237, December 1993, by N. J. Higham.
//-------------------------------------------------------------------//
pdtoep = function ( n, m, w, theta )
{
local ( n, m, w, theta )
global (pi)
if (!exist (m)) { m = n; }
if (!exist (w)) { w = rand (m, 1); }
if (!exist (theta)) { theta = rand (m, 1); }
if (max (size (w)) != m || max (size (theta)) != m)
{
error ("Arguments W and THETA must be vectors of length M.");
}
T = zeros(n,n);
E = 2*pi*( (1:n)'*ones(1,n) - ones(n,1)*(1:n) );
for (i in 1:m)
{
T = T + w[i] * cos( theta[i]*E );
}
return T;
};